home *** CD-ROM | disk | FTP | other *** search
- /*
- * UControlPanel.h (MPW 3.2)
- * Copyright ©1991 David Kreindler. All rights reserved.
- *
- * KNOWN BUGS AND SHORTCOMINGS:
- * [none]
- */
-
- #ifndef __UCONTROLPANEL__
- #define __UCONTROLPANEL__
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __UHANDLEOBJECT__
- #include <UHandleObject.h>
- #endif
-
- class TControlPanel: public THandleObject {
- public:
- TControlPanel(DialogPtr, short numItems);
- virtual void DoActivate(EventRecord *, long *cdevValue); // activDev
- virtual void DoClear(long *cdevValue); // clearDev
- virtual void DoCopy(long *cdevValue); // copyDev
- virtual void DoCursor(long *cdevValue); // cursorDev
- virtual void DoCut(long *cdevValue); // cutDev
- virtual void DoDeactivate(EventRecord *, long *cdevValue); // deActivDev
- virtual void DoHit(short, EventRecord *, long *cdevValue); // hitDev; the short is our item number, not the Dialog Manager’s
- virtual void DoInit(long *cdevValue); // initDev
- virtual void DoKeyEvent(EventRecord *, long *cdevValue); // keyEvtDev
- virtual void DoMac(long *cdevValue); // macDev
- virtual void DoNull(EventRecord *, long *cdevValue); // nulDev
- virtual void DoPaste(long *cdevValue); // pasteDev
- virtual void DoUndo(long *cdevValue); // undoDev
- virtual void DoUpdate(long *cdevValue); // updateDev
- protected:
- operator DialogPtr(); // returns the control panel dialog (is this overloading bad style???)
- short FindDItem(Point thePt); // overload; wrapper for the return value; returns the actual item id, not -1 as ::
- void GetDItem(short itemNo, short *itemType, Handle *, Rect *); // overload; wrapper for itemNo
- short Item(short); // returns the dialog manager’s item number; i.e., our item + fNumItems
- private:
- const DialogPtr fDialog; // the control panel dialog
- const short fNumItems; // the number of items preceding ours in the control panel’s dialog item list
- };
-
- void SetCursor(short); // overload; sets the cursor to a given CURS resource (this is here because this is example code; it should be in a library)
-
- /* —————————————————————————————————— inline definitions —————————————————————————————————— */
-
- inline void TControlPanel::DoActivate(EventRecord *, long *) {
- /* empty method */
- }
-
- inline void TControlPanel::DoClear(long *) {
- DlgDelete(fDialog);
- }
-
- inline void TControlPanel::DoCopy(long *) {
- DlgCopy(fDialog);
- }
-
- inline void TControlPanel::DoCut(long *) {
- DlgCut(fDialog);
- }
-
- inline void TControlPanel::DoDeactivate(EventRecord *, long *) {
- /* empty method */
- }
-
- inline void TControlPanel::DoHit(short, EventRecord *, long *) {
- /* empty method */
- }
-
- inline void TControlPanel::DoInit(long *) {
- /* empty method */
- }
-
- inline void TControlPanel::DoMac(long *cdevValue) {
- *cdevValue = false; // this base class does not run under any circumstances (assuming the 'mach' resource permits this to be called)
- }
-
- inline void TControlPanel::DoNull(EventRecord *, long *) {
- /* empty method */
- }
-
- inline void TControlPanel::DoPaste(long *) {
- DlgPaste(fDialog);
- }
-
- inline void TControlPanel::DoUndo(long *) {
- /* empty method */
- }
-
- inline void TControlPanel::DoUpdate(long *) {
- /* empty method */
- }
-
- inline short TControlPanel::FindDItem(Point thePt) {
- return ::FindDItem(fDialog, thePt) + fNumItems + 1;
- }
-
- inline void TControlPanel::GetDItem(short itemNo, short *itemType, Handle *item,
- Rect *itemRect) {
- ::GetDItem(fDialog, itemNo + fNumItems, itemType, item, itemRect);
- }
-
- inline short TControlPanel::Item(short itemNo) {
- return itemNo + fNumItems;
- }
-
- inline TControlPanel::operator DialogPtr() {
- return fDialog;
- }
-
- inline void SetCursor(short cursID) { // accepts CURS resource id
- SetCursor(*GetCursor(cursID)); // !!! we really ought to check for errors here
- }
-
- inline TControlPanel::TControlPanel(DialogPtr theDialog, short numItems):
- fDialog(theDialog), fNumItems(numItems) {
- }
-
- #endif